#coding=utf-8

from models import Message
from status.models import SystemStart
from django.shortcuts import get_object_or_404
from django.views.generic.simple import direct_to_template

def show_archive(request):
    '''Shows all messages from system start'''
        
    started = SystemStart.objects.latest('started')
    messages = Message.objects.filter (came_date__gte = started.started)

    return direct_to_template (request, 'archive.html', {'msgs': messages })

def show_message(request, msgid):
    '''Shows info about message of given id'''
    
    msg = get_object_or_404 (Message, pk=msgid)
    
    return direct_to_template (request, 'message.html', {'has_back': True, 'msg': msg })
